json-lint.js ➔ ?!?   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 12
nc 1
nop 1
dl 0
loc 17
rs 9.8
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A json-lint.js ➔ ... ➔ CodeMirror.registerHelper(ꞌlintꞌ) 0 12 1
1
// CodeMirror, copyright (c) by Marijn Haverbeke and others
2
// Distributed under an MIT license: http://codemirror.net/LICENSE
3
4
// Depends on jsonlint.js from https://github.com/zaach/jsonlint
5
6
// declare global: jsonlint
7
8
(function(mod) {
9
  if (typeof exports == "object" && typeof module == "object") // CommonJS
10
    mod(require("../../lib/codemirror"));
11
  else if (typeof define == "function" && define.amd) // AMD
0 ignored issues
show
Bug introduced by
The variable define seems to be never declared. If this is a global, consider adding a /** global: define */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
12
    define(["../../lib/codemirror"], mod);
13
  else // Plain browser env
14
    mod(CodeMirror);
0 ignored issues
show
Bug introduced by
The variable CodeMirror seems to be never declared. If this is a global, consider adding a /** global: CodeMirror */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
15
})(function(CodeMirror) {
16
"use strict";
17
18
CodeMirror.registerHelper("lint", "json", function(text) {
19
  var found = [];
20
  jsonlint.parseError = function(str, hash) {
0 ignored issues
show
Bug introduced by
The variable jsonlint seems to be never declared. If this is a global, consider adding a /** global: jsonlint */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
21
    var loc = hash.loc;
22
    found.push({from: CodeMirror.Pos(loc.first_line - 1, loc.first_column),
23
                to: CodeMirror.Pos(loc.last_line - 1, loc.last_column),
24
                message: str});
25
  };
26
  try { jsonlint.parse(text); }
27
  catch(e) {}
0 ignored issues
show
Coding Style Comprehensibility Best Practice introduced by
Empty catch clauses should be used with caution; consider adding a comment why this is needed.
Loading history...
28
  return found;
29
});
30
31
});
32